"""
接口路由 VO
"""

import utils.enum_utils as enum
from models import (
    VOBase,
    VOPage,
)
from my_typing import *
from utils.data_utils.special import ObjectIdStr
from utils.mock_utils import Demo
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    ListField,
    NormalField,
)


class APIRouteListVO(VOBase):
    """ 接口路由 | 列表 | VO """

    route_id: ObjectIdStr = CharField(..., title="路由 ID（ObjectId 字符串）", examples=[Demo.id])

    dependencies: ListStr = ListField(..., title="依赖项")
    deprecated: bool = NormalField(False, title="是否已废弃")
    methods: list[enum.Method] = ListField(..., title="请求方法")
    name: str = CharField(..., title="路由名称")
    path: str = CharField(..., title="请求路径")
    summary: str = CharField(..., title="路由描述")
    tags: list[enum.SwaggerTag] = ListField(..., title="标签")
    unique_id: str = CharField(..., title="唯一 ID")
    update_time: str = CharField(..., title="更新时间", min_length=19, max_length=19, examples=[Demo.dt_str])


class APIRouteDetailVO(APIRouteListVO):
    """ 接口路由 | 详情 | VO """

    include_in_schema: bool = NormalField(..., title="是否在 Swagger 中显示")
    path_regex: str = CharField(..., title="路径正则表达式")
    request_model: StrOrNone = CharField(..., title="请求模型")
    response_model: StrOrNone = CharField(..., title="响应模型")


class APIRouteListPage(VOPage[APIRouteListVO]):
    """ 接口路由 | 列表 | 分页 """
